//
//  LoginViewController.m
//  UI_xiangmu
//
//  Created by dlios on 15-4-28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LoginViewController.h"
#import "RegisterViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createLoginView];
}

#pragma mark 创建视图
- (void)createLoginView
{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"登陆";
    
    UIImage *image = [UIImage imageNamed:@"login"];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [imageView setImage:image];
    [self.view addSubview:imageView];
    [imageView release];
    
    //用户
    UILabel *userLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 150, 40)];
    userLabel.text = @"用户名";
    [self.view addSubview:userLabel];
    [userLabel release];
    UITextField *userTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 80, 200, 40)];
    userTextField.layer.borderWidth = 0.5;
    userTextField.layer.cornerRadius = 5;
    userTextField.placeholder = @"请输入用户名";
    userTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:userTextField];
    
    //密码
    UILabel *passWordLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 130, 150, 40)];
    passWordLabel.text = @"密码";
    [self.view addSubview:passWordLabel];
    [passWordLabel release];
    UITextField *passWordTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 180, 200, 40)];
    passWordTextField.layer.borderWidth = 0.5;
    passWordTextField.layer.cornerRadius = 5;
    passWordTextField.placeholder = @"请输入密码";
    passWordTextField.secureTextEntry = YES;
    passWordTextField.clearsOnBeginEditing = YES;
    [self.view addSubview:passWordTextField];
    
    //登陆Button
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    loginButton.frame = CGRectMake(20, 280, 70, 40);
    loginButton.layer.borderWidth = 0.5;
    loginButton.layer.cornerRadius = 5;
    loginButton.backgroundColor = [UIColor whiteColor];
    [loginButton setTitle:@"登陆" forState:UIControlStateNormal];
    [loginButton addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];
    
    //注册
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeSystem];
    registerButton.frame = CGRectMake(110, 280, 70, 40);
    registerButton.layer.borderWidth = 0.5;
    registerButton.layer.cornerRadius = 5;
    registerButton.backgroundColor = [UIColor whiteColor];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerButton];
}

#pragma mark 登陆点击方法
- (void)loginAction
{
    NSLog(@"登陆");
}

#pragma mark 注册点击方法
- (void)registerAction
{
    NSLog(@"注册");
    RegisterViewController *registerVC = [[RegisterViewController alloc] init];
    [self.navigationController pushViewController:registerVC animated:YES];
    [registerVC release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
